package com.google.gson.internal;

import com.google.gson.b.a;
import com.google.gson.b.d;
import com.google.gson.internal.bind.y;
import com.google.gson.j;
import com.google.gson.l;
import com.google.gson.n;
import com.google.gson.q;
import java.io.IOException;
import java.io.Writer;

public final class k {
    public static j a(a aVar) throws n {
        Object obj = 1;
        try {
            aVar.f();
            obj = null;
            return (j) y.O.b(aVar);
        } catch (Throwable e) {
            if (obj != null) {
                return l.a;
            }
            throw new com.google.gson.k(e);
        } catch (Throwable e2) {
            throw new q(e2);
        } catch (Throwable e22) {
            throw new com.google.gson.k(e22);
        } catch (Throwable e222) {
            throw new q(e222);
        }
    }

    public static Writer a(Appendable appendable) {
        return appendable instanceof Writer ? (Writer) appendable : new l(appendable, null);
    }

    public static void a(j jVar, d dVar) throws IOException {
        y.O.a(dVar, jVar);
    }
}
